﻿<controls:ChildWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
    x:Class="Earthwatchers.UI.GUI.Controls.Ranking"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:ext="clr-namespace:Earthwatchers.UI.Extensions"
    xmlns:loaders="clr-namespace:Earthwatchers.UI.GUI.Loaders"
    Width="650" Height="490" 
    Style="{StaticResource GPDefaultChildWindow}" 
    Title="{Binding Path=Ranking, Source={StaticResource Labels}}">
    <controls:ChildWindow.Resources>
        <ext:CommentDeleteVisibilityConverter x:Key="currentRankingVisibilityConverter" />
        <ext:CurrentRankingBoldConverter x:Key="currentRankingBoldConverter" />
    </controls:ChildWindow.Resources>
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Grid.Column="0" x:Name="contestGrid" Visibility="Collapsed" MinWidth="300">
            <Grid.RowDefinitions>
                <RowDefinition Height="45" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock x:Name="TitleContestTextBox" Grid.Row="0" Grid.ColumnSpan="2" Foreground="#FF9db80e"
                    FontWeight="SemiBold" FontSize="24" Margin="3,0,0,0" FontFamily="Arial" VerticalAlignment="Center" />
            <ItemsControl x:Name="rankingContestList" Grid.Row="1" BorderThickness="0" Background="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="2,0,10,0" Height="30">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="70" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" HorizontalAlignment="Right" Text="{Binding Id}" Margin="4" FontWeight="{Binding Path=Id, Converter={StaticResource currentRankingBoldConverter}}" Foreground="#FF9db80e" FontFamily="Arial" FontSize="16" FontStyle="Italic" VerticalAlignment="Center" />
                            <Border Grid.Column="1" CornerRadius="4" BorderBrush="#FFc7c7c7" BorderThickness="1">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="../../Resources/Images/user-active.png" Visibility="{Binding Path=EarthwatcherId, Converter={StaticResource currentRankingVisibilityConverter} }" VerticalAlignment="Center" HorizontalAlignment="Right" Stretch="None" />
                                        <TextBlock Text="{Binding Action}" FontFamily="Arial" FontWeight="{Binding Path=Id, Converter={StaticResource currentRankingBoldConverter}}" Foreground="#FF414141" FontSize="14" Margin="2" VerticalAlignment="Center" />

                                    </StackPanel>
                                    <TextBlock Grid.Column="1" HorizontalAlignment="Right" Margin="2" FontWeight="{Binding Path=Id, Converter={StaticResource currentRankingBoldConverter}}" FontFamily="Arial" Text="{Binding Points}" Foreground="#FF7c8e24" FontSize="14" VerticalAlignment="Center" />
                                </Grid>
                            </Border>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Grid>
        <Border x:Name="globalGrid" Grid.Column="1" Margin="10,0,0,0" Visibility="Visible" CornerRadius="8" Background="#FFecf0d5" MinWidth="280">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="45" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock x:Name="TitleTextBox" Grid.Row="0" Grid.ColumnSpan="2" Foreground="#FF9db80e" FontWeight="SemiBold" FontSize="18" Margin="5" Text="{Binding Path=Ranking2, Source={StaticResource Labels}}" FontFamily="Arial" VerticalAlignment="Center" />
                <ItemsControl x:Name="rankingList" Grid.Row="1" BorderThickness="0" Background="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="2,0,10,0" Height="30">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="60" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" HorizontalAlignment="Right" Text="{Binding Id}" Margin="4" FontWeight="{Binding Path=Id, Converter={StaticResource currentRankingBoldConverter}}" Foreground="#FF414141" FontFamily="Arial" FontSize="14" FontStyle="Italic" VerticalAlignment="Center" />
                                <Border Grid.Column="1">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="../../Resources/Images/user-active.png" Visibility="{Binding Path=EarthwatcherId, Converter={StaticResource currentRankingVisibilityConverter}}" VerticalAlignment="Center" HorizontalAlignment="Right" Stretch="None" />
                                            <TextBlock Text="{Binding Action}" FontWeight="{Binding Path=Id, Converter={StaticResource currentRankingBoldConverter}}" FontFamily="Arial" Foreground="#FF414141" FontSize="13" Margin="2" VerticalAlignment="Center" />
                                        </StackPanel>
                                        <TextBlock Grid.Column="1" HorizontalAlignment="Right" Margin="2" FontFamily="Arial" Text="{Binding Points}" FontWeight="{Binding Path=Id, Converter={StaticResource currentRankingBoldConverter}}" Foreground="#FF7c8e24" FontSize="13" VerticalAlignment="Center" />
                                    </Grid>
                                </Border>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </Border>

        <Grid x:Name="loadinAnim" Visibility="Visible" Grid.ColumnSpan="2">
            <loaders:_3D Margin="0,0,0,0" />
            <TextBlock Text="{Binding Path=Cargando, Source={StaticResource Labels}}" Margin="0,50,0,0" FontFamily="Arial" FontSize="13" Foreground="#FF333333" VerticalAlignment="Center" HorizontalAlignment="Center" />
        </Grid>

        <Border x:Name="ContestFooterBorder" Visibility="Collapsed" Grid.Row="1" Height="40" Grid.ColumnSpan="2" Margin="0,10,0,0" Background="{StaticResource GridFooterBrush}" CornerRadius="0,0,8,8">
            <TextBlock x:Name="ContestFooterTextBox" Grid.Row="0" Grid.ColumnSpan="2" Foreground="#FF414141" FontWeight="SemiBold" FontSize="14" Margin="5" Text="{Binding Path=Ranking2, Source={StaticResource Labels}}" FontFamily="Arial" VerticalAlignment="Center" />
        </Border>
    </Grid>
</controls:ChildWindow>